#!/usr/bin/python

from ROOT import TFile,TH1,TTree,TIter,TKey

inputHist='mc12.lailin.prw.root'
tf=TFile(inputHist)
list_hist=tf.GetListOfKeys()
next=TIter(tf.GetListOfKeys())
print 'number of keys: ', list_hist.GetSize()
for i in range(list_hist.GetSize()):
  key=next.Next()
  obj=key.ReadObj()
  if obj.IsA().InheritsFrom(TH1.Class()):
    print 'this is a hist: ', obj.GetName(), ' entries: ', obj.GetEntries()
  if obj.IsA().InheritsFrom(TTree.Class()):
    print 'this is a TTree: ', obj.GetName(), ' entries: ', obj.GetEntries()
